package com.dliu.javadesign.create.abstractfactory;

/**
 * @author yanglei
 * date 2021/3/29 9:48
 */
public interface CarFactory {
    Color doColor(String color);
    Type doType(String type);
}

class CarColorFactory implements CarFactory {
    @Override
    public Color doColor(String color) {
        switch (color){
            case "red": return new Red();
            case "black": return new Black();
        }
        return null;
    }

    @Override
    public Type doType(String type) {
        return null;
    }
}

class CarTypeFactory implements CarFactory {
    @Override
    public Color doColor(String color) {
        return null;
    }

    @Override
    public Type doType(String type) {
        switch (type){
            case "bus": return new Bus();
            case "bike": return new Bike();
        }
        return null;
    }
}
